<?php
namespace app\shop\controller;
use think\Controller;
use think\request;
use think\Db;
use app\shop\controller\Common;
class Index extends Common{
	public function index(){
		session('url',request()->url());
		$this->assign("bottom_type","1");
		$this->assign("title","番茄积分");
		$data=Db::table("zz_shop")->order('shop_id desc')->select();
		$this->assign("data",$data);

		//查询分类列表
		$category=Db::table("zz_category")->order('sort')->select();
		$this->assign('category',$category);
		$categoryshow=Db::table("zz_category")->where("is_show","1")->order('sort')->select();
		foreach ($categoryshow as $key => $value) {
			$categoryshow[$key]["goodlist"]=Db::table("zz_goods")->where('state','1')->where("promotion_type","1")->where('category_id',$value["category_id"])->order('sort')->select();
		}
		
		$this->assign('categoryshow',$categoryshow);
		return $this->fetch();
	}

	public function promotion(){
		$goodlist=Db::table('zz_goods')->where('state','1')->where("promotion_type","1")->select();
		$this->assign('data',$goodlist);
		$this->assign("bottom_type","2");
		$this->assign("title","特价商品");
		return $this->fetch('promotion_good');
	}
	public function categoryGood(){
		$category_id=request()->get("category_id");
		$goodlist=Db::table("zz_goods")->where("category_id",$category_id)->where('state',"1")->select();
		$this->assign("data",$goodlist);
		$category=Db::table("zz_category")->where("category_id",$category_id)->find();
		$this->assign("category",$category);
		$this->assign("bottom_type","1");
		$this->assign("title","番茄积分");
		return $this->fetch('category_good');
	}
}